<?php


namespace Modules\Admin\Http\Controllers\Authorization\Role;


use Illuminate\Support\Facades\DB;
use Modules\Common\General\Security\Authorization\Manager;
use Modules\Common\Util\Api;

class CancelExtends
{
    /**
     * @Route(path=/api/admin/authorization/role/extend method=delete)
     */
    public function index()
    {
        Api::validate( ['base_role_ids' => 'array[integer]', 'role_id' => 'integer']);
        DB::transaction(function (){
            $m = new Manager();
            foreach (request('base_role_ids') as $baseRoleId) {
                $m->cancelExtendsRole(request('role_id'), $baseRoleId);
            }
        });
        return Api::success();
    }

}
